package org.neuedu.ssmp.crm.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.neuedu.ssmp.crm.entity.SysRole;
import org.neuedu.ssmp.crm.entity.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author MoonHolder
 * @since 2019-12-09
 */
public interface SysUserMapper extends BaseMapper<SysUser> {

    @Select("select username from sys_user y join sys_role s on y.role_id=s.id where s.name='客户经理'")
    List<SysUser> list();

    @Select("select * from sys_user where username=#{name} and password=#{pwd} ")
    SysUser selectapp(@Param("name") String name,@Param("pwd") String pwd);


    @Select("select s.username,y.name from sys_role y join sys_user s on y.id=s.role_id where s.role_id=#{id} and s.username=#{name}")
    SysRole select(@Param("id") Integer id ,@Param("name") String name);

    @Select("select u.*,r.name roleName from sys_user u join  sys_role r on u.role_id=r.id")
    List<SysUser> show();

    @Update("delete from sys_user where id=#{id} " )
    boolean deleteById(@Param("id")Integer id);

    @Select("select id,username,password,role_id,is_del from sys_user where username=#{username} ")
    List<SysUser> exist(@Param("username")String username);
}
